package cn.ichensw.otherworldlystationbackend.controller;


import cn.ichensw.otherworldlystationbackend.common.BaseResponse;
import cn.ichensw.otherworldlystationbackend.common.DeleteRequest;
import cn.ichensw.otherworldlystationbackend.common.ResultUtils;
import cn.ichensw.otherworldlystationbackend.model.dto.filmtelevision.FilmTelevisionAddRequest;
import cn.ichensw.otherworldlystationbackend.model.dto.filmtelevision.FilmTelevisionQueryRequest;
import cn.ichensw.otherworldlystationbackend.model.dto.filmtelevision.FilmTelevisionUpdateRequest;
import cn.ichensw.otherworldlystationbackend.model.vo.filmtelevision.FilmTelevisionVO;
import cn.ichensw.otherworldlystationbackend.service.FilmTelevisionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 影视接口
 *
 * @author csw
 */
@Api(value = "影视管理接口", tags = "FilmTelevisionController")
@RestController
@RequestMapping("/filmTelevision")
@Slf4j
public class FilmTelevisionController {

    @Resource
    private FilmTelevisionService filmTelevisionService;

    /**
     * 查询影视列表
     *
     * @param filmTelevisionQueryRequest 影视信息请求类
     * @return Page<FilmTelevisionVO>
     */
    @ApiOperation("查询影视列表")
    @PostMapping("/list")
    public BaseResponse<List<FilmTelevisionVO>> listFilmTelevision(@RequestBody FilmTelevisionQueryRequest filmTelevisionQueryRequest, HttpServletRequest request) {
        return ResultUtils.success(filmTelevisionService.listFilmTelevision(filmTelevisionQueryRequest, request));
    }

    /**
     * 根据ID查询影视信息
     *
     * @param id 影视ID
     * @return FilmTelevisionVO 影视信息
     */
    @ApiOperation("根据ID查询影视信息")
    @PostMapping("/info/{id}")
    public BaseResponse<FilmTelevisionVO> getFilmTelevisionById(@PathVariable("id") Long id, HttpServletRequest request) {
        return ResultUtils.success(filmTelevisionService.getFilmTelevisionById(id, request));
    }

    /**
     * 修改影视信息
     *
     * @param filmTelevisionUpdateRequest 影视信息请求类
     * @return Boolean
     */
    @ApiOperation("修改影视信息")
    @PostMapping("/update")
    public BaseResponse<Boolean> updateFilmTelevision(@RequestBody FilmTelevisionUpdateRequest filmTelevisionUpdateRequest, HttpServletRequest request) {
        boolean flag = filmTelevisionService.updateFilmTelevision(filmTelevisionUpdateRequest, request);
        return flag ? ResultUtils.success("更新成功") : ResultUtils.fail("更新失败");
    }

    /**
     * 添加影视信息
     *
     * @param filmTelevisionAddRequest 影视信息请求类
     * @return Boolean
     */
    @ApiOperation("添加影视信息")
    @PostMapping("/add")
    public BaseResponse<Long> addFilmTelevision(@RequestBody FilmTelevisionAddRequest filmTelevisionAddRequest, HttpServletRequest request) {
        return ResultUtils.success(filmTelevisionService.addFilmTelevision(filmTelevisionAddRequest, request));
    }

    /**
     * 删除影视信息
     *
     * @param deleteRequest 删除请求类
     * @return Boolean
     */
    @ApiOperation("删除影视信息")
    @PostMapping("/delete")
    public BaseResponse<Boolean> deleteFilmTelevision(@RequestBody DeleteRequest deleteRequest, HttpServletRequest request) {
        return ResultUtils.success(filmTelevisionService.deleteFilmTelevision(deleteRequest, request));
    }


}
